<?php

class Welcome extends MY_Controller {
	
    public $filename = 'welcome/index';
    public $content=array();
    
	public function __construct(){
		parent::__construct();
        $this->load->library('session');
        $this->load->helper('url');
		$this->load->model('Se','se',TRUE);
	}
	
	
	public function index(){
        $offset  = $this->uri->segment(3);
        $title = '';
        $pages = $this->se->getdata($title,$offset,1);
        $url= site_url('welcome/index');
        $pagenation = pagenation($pages,$url);
        $list = $this->se->getdata($title,$offset,0);
        $this->content = array(
                            'list'=>$list,
                            'page'=>$pagenation,
                            'title'=>$title,
                            'pages'=>$pages
                            );
        $this->render($this->filename,$this->content);
	}
    
    public function search(){
        $offset  = $this->uri->segment(3);
        $title = isset($_POST['title']) ? $_POST['title'] : $this->session->userdata("title") ;
		$session_array = array(
			"title" => $title,
		);
		$data['search'] 	= 	$session_array;
		$this->session->set_userdata($session_array);
        $pages = $this->se->getdata($title,$offset,1);
        $url= site_url('welcome/search');
        $pagenation = pagenation($pages,$url);
        $list = $this->se->getdata($title,$offset,0);
        $this->content = array(
                            'list'=>$list,
                            'page'=>$pagenation,
                            'title'=>$title,
                            'pages'=>$pages
                            );
        $this->render($this->filename,$this->content);
	}
}